<?php
require APPPATH.'/libraries/REST_Controller.php';

class Api extends REST_Controller {

	public function __construct()
	{
		parent::__construct();
	}

	public function feeling_put()
	{
		$data = array(
				'feeling_name' => $this->put('feeling_name'),
				'latitude' => $this->put('latitude'),
				'longitude' => $this->put('longitude'),
				'date' => date('Y-m-d H:i:s')
			);

		dlog($data);
		
		$id = $this->api_model->createFeeling($data);

		if($id)
		{
			$this->response(array('status' => 'success', 'id' => $id), 200);	
		}
		else
		{
			$this->response(array('status' => 'failed'), 400);
		}
	}

	public function feelings_get()
	{
		$feelings = $this->api_model->getFeelings();

		if($feelings)
		{
			$this->response($feelings->result(), 200); // 200 being the HTTP response code
		}
		else
		{
			$this->response(array('error' => "Couldn't find any feelings!"), 404);
		}
	}
}